package org.example.redisdemo.controller;

import org.example.redisdemo.model.Test;
import org.example.redisdemo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController  /*==@Controller + @ResponseBody*/
public class IndexController {
    @Autowired
    TestService testService;
    @GetMapping("/show")
    public Test getTest1(){
        return testService.getTest(1);
    }

    @GetMapping("/show2")
    public Test getTest2(){
        return testService.getTest2(1);
    }

    @GetMapping("/up")
    public String updateTest1(){
        Test test = new Test();
        test.setId(1);
        test.setName("value");
        testService.upDateTest(test);
        return "OK";
    }
    @GetMapping("/up2")
    public String updateTest2(){
        Test test = new Test();
        test.setId(1);
        test.setName("252525");
        testService.upDateTest(test);
        return "OK2";
    }

//    @ResponseBody
    @RequestMapping("/index")
    public Map<String, String> Index(){
        Map map = new HashMap<String, String>();
        map.put("北京","北方城市");
        map.put("深圳","南方城市");

        return map;
    }


}
